package com.foo.aop.Aspect;

import java.util.Arrays;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.Signature;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

@Aspect
public class AspectLogger 
{
	private final Log logger = LogFactory.getLog(this.getClass());
	
	@Pointcut("execution(* com.foo.DataProvider.*.*(..))")
    public void inceptorMethods(){}
	
	@Before("com.foo.aop.Aspect.SystemArchitecture.providerBusinessService()")
	public void logEntry(JoinPoint joinPoint) 
	{
		StringBuilder logMessage = new StringBuilder();
		Signature signature =  joinPoint.getSignature();
		String methodName = signature.getName();
		String className = joinPoint.getTarget().getClass().getName();
		String arguments = Arrays.toString(joinPoint.getArgs());
		logMessage.append("\nLogging Information \n Class Name: "+ className +"\n The method currently executing is: "
					+ methodName +"\n Arguments entered to the method are: " + arguments +"\n");
		logger.info(logMessage.toString());
	}
	
	
	
	
	
}
